﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using CommonLib.Pattern.FSM;
using CommonLib;
using Newtonsoft.Json;
public class FSMEnemy : FSMMachineBase, IInitFromConfig
{
	public RoleCtrl roleCtrl;
	public List<TransitionLevel> Levles { get; protected set; } 

	public FSMEnemy(string _name, IState _defaultState, RoleCtrl _role) : base(_name, _defaultState)
	{
		this.roleCtrl = _role;
		_ConfigInit(GameResource.DocumentResMgr.GetDocumentPathByName("EnemyAI"));
	}

	public void _ConfigInit(string _fileName)
	{
		string jsonString = GameResourceLoader.Instance.LoadJsonFileInPersistent(_fileName);
		List <TransitionLevel> levels = JsonConvert.DeserializeObject<List<TransitionLevel>>(jsonString);
		if (levels.Count <= 0)
			Debug.LogError("EnemyAI配置文件未加载成功");
		//Debug.Log(levels.Count);
		Levles = levels;
	}

	
}


